package com.bsj.power.pls.queue.service.impl;

import com.bsj.consumerQ.method.QueueAndRunT;
import com.bsj.power.pls.queue.service.QueueService;
import com.bsj.power.pls.queue.service.impl.handle.QueueHumanFaceHandle;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author LiJiaXin
 * @version 1.0.0
 * @description 人脸数据弹卡
 * @time 2025/1/8 15:56
 */
@Service("QueueHumanFace")
@Slf4j
public class QueueHumanFaceImpl implements QueueService {

    private QueueAndRunT queue = null;

    private static final String NAME = "QueueHumanFace";

    @Autowired
    private QueueHumanFaceHandle queueHumanFaceHandle;

    @Override
    public void init() {
        if (queue == null) {
            queue = new QueueAndRunT(com.bsj.power.job.config.constant.QueueConstant.worker, com.bsj.power.job.config.constant.QueueConstant.popCount, com.bsj.power.job.config.constant.QueueConstant.maxWorker);
            queue.start(NAME, queueHumanFaceHandle);
        }
    }

    @Override
    public void stop() {
        if (queue != null) {
            queue.stop();
        }
    }

    @Override
    public void doRun(Object bytes) throws Exception {
        if (queue == null) {
            log.error("QueueHumanFaceImpl 未初始化");
            init();
        }
        queue.push(bytes);
    }

    @Override
    public void doPush(byte[] bytes) throws Exception {

    }

}
